﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.OMM.HealthMonitor.Entity.Router;
using Sinacor.OMM.HealthMonitor.Collector;
using Sinacor.OMM.HealthMonitor.Configuration;

namespace Sinacor.OMM.HealthMonitor.Server.Controller
{
    public class HsCtrlRouterShdms
    {

        public static RouterData CheckExpiration(RouterData routerData)
        {
            RouterData ret = null;

            if (routerData != null)
            {
                int secondsToExpire = OMM.HealthMonitor.Configuration.HealthMonitorConfigurationManager.HealthMonitorConfiguration.TimeToRefreshMonitorSeconds * 10;
                
                double timeElaspseSinceLastUpdate = DateTime.Now.Subtract(routerData.LastUpdate).TotalSeconds;

                if (timeElaspseSinceLastUpdate >= secondsToExpire)
                    ret = null;
                else
                    ret = routerData;
            }

            return ret;
        }
    }
}
